package com.hard;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Lxk on 2019/5/12.
 */

class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;
    TreeNode(int x) { val = x; }
}

public class Solution145 {

    void postorderVisit(TreeNode node, List<Integer> res){
        if(node == null){
            return ;
        }
        postorderVisit(node.left,res);
        postorderVisit(node.right,res);
        res.add(node.val);
    }

    public List<Integer> postorderTraversal(TreeNode root) {
        List<Integer> res = new ArrayList<>();
        postorderVisit(root,res);
        return res;
    }

}
